package write;

import java.io.Writer;

import javax.xml.transform.TransformerException;

import reader.ClassMap;
import reader.components.IComponentRW;
import reader.xml.XMLContext;

import components.Form;

public class XMLWrite implements IWrite {

    public static final String FORM = "form";

    public void write(Form form, Writer writer) {
        XMLContext context = XMLContext.createWriteRoot(FORM);
        IComponentRW component = ClassMap.getInstance().getComponentRW("Form", null);
        component.write(form, context);
        try {
            context.save(writer);
        } catch (TransformerException e) {
            throw new RuntimeException(e);
        }
    }

}
